package main;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


public class Word {
	private String word;
	private String type1;
	private HashMap<String,Integer> types;
	private String type2;
	private int count;
	private int ct1;
	private int ct2;
	
	public Word(String word){
		this.word = word;
		ct1 = 0;
		ct2 = 0;
		count = 1;
		types = new HashMap<String,Integer>();

	}
	
	public String getName(){
		return word;
	}
	
	public void incrementType(String type){
		if(types.containsKey(type)){
			types.put(type, types.get(type)+1);
		}else{
			types.put(type,1);
		}
	}
	

	
	public void incrementCount(){
		count++;
	}

	public int getCount() {
		
		return count;
	}

	public String getTypeOc() {

		Iterator it = types.entrySet().iterator();
		String output = "";
		while (it.hasNext()) {
			Map.Entry pairs = (Map.Entry) it.next();
			output += pairs.getKey() + " = " + pairs.getValue() + " ";

		}
		return output;
	}
	
	public ArrayList<String> getTypes(){
		ArrayList<String> ts = new ArrayList<String>();
		
		
		Iterator it = types.entrySet().iterator();
		String output = "";
		while (it.hasNext()) {
			Map.Entry pairs = (Map.Entry) it.next();
	
			ts.add((String) pairs.getKey());

		}
		return ts;
		
	}
		
		
	

	public String mostFrequent() {

		String out = "";
		int best = 0;
		Iterator it = types.entrySet().iterator();
		String output = "";
		while (it.hasNext()) {
			Map.Entry pairs = (Map.Entry) it.next();
			if ((Integer) pairs.getValue() > best) {
				best = (Integer) pairs.getValue();
				out = pairs.getKey().toString();
			}
			output += pairs.getKey() + " = " + pairs.getValue() + " ";

		}
		return out;
	}
}
